﻿using System;
using System.Collections.Generic;
using System.Text;

namespace unitlib
{
    public readonly struct Unit_mm4 : IUnit
    {
        public double Value { get; }
        public string Unit => "mm^4";

        public string LatexUnit => "\\mathrm{mm^4}";

        public Unit_mm4(double value) { Value = value; }
        public Unit_mm4 Round(int digits) => new Unit_mm4(Math.Round(Value, digits));
        //数值与字符串转换
        public override string ToString() => Value.ToString();
        public static explicit operator Unit_mm4(double value) => new Unit_mm4(value);
        public static explicit operator double(Unit_mm4 value) => value.Value;
        public static implicit operator Unit_mm4(string value) => new Unit_mm4(value.Parse());
        //比较运算
        public static bool operator ==(Unit_mm4 left, Unit_mm4 right) => left.Equals(right);
        public static bool operator !=(Unit_mm4 left, Unit_mm4 right) => !left.Equals(right);
        public override bool Equals(object obj) => obj is Unit_mm4 other && other.Value == Value;
        public override int GetHashCode()
        {
            unchecked
            {
                return GetType().GetHashCode() * 31 + Value.GetHashCode();
            }
        }
        //常规运算
        public static Unit_mm4 operator +(Unit_mm4 left, Unit_mm4 right) => new Unit_mm4(left.Value + right.Value);
        public static Unit_mm4 operator -(Unit_mm4 left, Unit_mm4 right) => new Unit_mm4(left.Value - right.Value);
        public static Unit_mm4 operator *(Unit_mm4 left, UnitValue right) => new Unit_mm4(left.Value * right.Value);
        public static Unit_mm4 operator *(UnitValue left, Unit_mm4 right) => new Unit_mm4(left.Value * right.Value);
        public static Unit_mm4 operator /(Unit_mm4 left, UnitValue right) => new Unit_mm4(left.Value / right.Value);
        public static UnitValue operator /(Unit_mm4 left, Unit_mm4 right) => new UnitValue(left.Value / right.Value);
        //新增运算  
    }
}
